﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace VoteUphold
{

    /// <summary>
    /// 获取或写入配置类
    /// </summary>
    internal class ConfigOperate
    {
        private readonly string _filePath;
        private XDocument _xd;

        /// <summary>
        /// XML文件路径
        /// </summary>
        /// <param name="filePath"></param>
        public ConfigOperate(string filePath)
        {
            this._filePath = filePath;
            this._xd = XDocument.Load(this._filePath);
        }

        /// <summary>
        /// 获取值
        /// </summary>
        /// <typeparam name="Tt"></typeparam>
        /// <returns></returns>
        public  Tt GetValue<Tt>(string nodeName)
        {
            XElement xes = this._xd.Root.Element(XName.Get(nodeName));
            return (Tt)Convert.ChangeType(xes.Value, typeof(Tt));

        }
       

    }

}
  //XElement xe = xes.Descendants().First(x =>
  //          {
                 
               
  //          });
